<template>
  <div class="company-style">
    <!-- 导航栏 start -->
    <van-nav-bar title="修改密码" left-arrow fixed @click-left="$router.back()"/>
    <!-- 导航栏 end -->

    <!-- 内容 -->
    <div class="user">
      <van-form @submit="onSubmit" class="form">
        <van-field v-model="password" size="large" type="password" name="密码" placeholder="请输入新密码" :rules="[{ required: true, message: '请填写新密码' }]" style="font-size: 16px" />
        <van-field v-model="password2" size="large" type="password" name="密码" placeholder="请确认新密码" :rules="[{ required: true, message: '请填写新密码' }]" style="font-size: 16px" />
        <div class="btns">
          <van-button round block type="info" native-type="submit" >确定</van-button>
        </div>
      </van-form>
    </div>
  </div>
</template>

<script>
import { NavBar, Form, Field, Button, Toast, Dialog } from "vant";
export default {
  name: "LoginPage",
  components: {
    [NavBar.name]: NavBar,
    [Form.name]: Form,
    [Field.name]: Field,
    [Button.name]: Button,
  },
  // 定义属性
  data() {
    return {
			password:'',
			password2:''
		};
  },
  // 方法集合
  methods: {
		onSubmit(){
			if(this.password!=this.password2){Toast('两次密码输入不一致');return;}
			 this.$api.post('/CompanyAccount/ModifyPassword',{newPassword:this.password}).then(res=>{
				 if(res.success){
					 Dialog.alert({title:'提示',message:res.msg}).then(()=>{
						 this.$router.replace({name:'company-login'})
					 })
				 }
				 else{
					 Toast(res.msg)
				 }
				 
			 })
		}
	},
};
</script>

<style lang="less">
@import "vant/lib/index.less";
@import "@/assets/css/company.less";
@import "@/assets/css/company.css";
</style>